﻿Imports HMSLibrary
Imports Microsoft.ApplicationBlocks.Data
Imports System.Data
Imports HMSDataLayer

Public Class NextContactControl
    Implements IHMSData

    Public Property ID As Integer Implements HMSLibrary.IHMSData.ID

    Public Function DataValidation() As Boolean Implements HMSLibrary.IHMSData.DataValidation
        DataValidation = False
        Try
            If AppointDateDatePicker.SelectedDate Is Nothing Then
                CommonMessages.ShowValidationMsg("Please select date!")
                Exit Function
            End If

            If String.IsNullOrEmpty(ContactTypeComboBox.Text) Then
                CommonMessages.ShowValidationMsg("Please enter contact type!")
                Exit Function
            End If
            DataValidation = True
        Catch ex As Exception
            AppCommon.LogError(ex)
        End Try
    End Function

    Public Sub LoadData(ByVal ID As Integer) Implements HMSLibrary.IHMSData.LoadData
        ActionMode = FormAction.EDIT
    End Sub

    Public Function SaveData() As Boolean Implements HMSLibrary.IHMSData.SaveData
        If DataValidation() = False Then Return False
        Dim dataProvider As New MasterDataLayer()
        Dim alert As New Alerts
        'alert.AlertDate = AlertDatePicker.SelectedDate
        'alert.Subject = SubjectTextBox.Text.Trim
        'alert.Note = NoteTextBox.Text.Trim
        If dataProvider.SaveAlert(alert, ActionMode) = True Then
            Return True
        End If
    End Function

    Public Property ActionMode As HMSLibrary.FormAction Implements HMSLibrary.IHMSData.ActionMode

    Private Sub ClientEntryUserControl_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
        AddNew()
    End Sub

    Public Sub AddNew() Implements HMSLibrary.IHMSData.AddNew
        ActionMode = FormAction.ADD
        AppointmentTime.Value = Date.Now
        Dim dataProvider As New MasterDataLayer()
        Dim lst As List(Of Lookups)

        lst = dataProvider.GetLookupList(LookupTypes.ContactType)
        ContactTypeComboBox.ItemsSource = lst
    End Sub

    Public Sub FindData() Implements IHMSData.FindData
        MainGrid.Visibility = Visibility.Collapsed
        'FindStackPanel.Visibility = Visibility.Visible
        Dim DataObject As MasterDataLayer
        Dim DataCollection As Object
        DataObject = New MasterDataLayer()
        DataCollection = DataObject.GetAlertsList
        'SearchDataGrid.ItemsSource = DataCollection
    End Sub

    Public Sub BackView() Implements IHMSData.BackView
        MainGrid.Visibility = Visibility.Visible
        'FindStackPanel.Visibility = Visibility.Collapsed
    End Sub

    Private Sub DeleteButton_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)

    End Sub

    Private PatientID As Long
    Public Sub New(ByVal _PatientID As Long)

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        Me.PatientID = _PatientID
    End Sub
End Class
